//
//  NewHomeModel.m
//  quxiangtao
//
//  Created by E人一铺 on 2019/2/25.
//  Copyright © 2019年 shanhaijin. All rights reserved.
//

#import "NewHomeModel.h"



@implementation NewHomeModel

+ (NSDictionary *)mj_replacedKeyFromPropertyName
{
    return @{
             // 模型属性: JSON key, MJExtension 会自动将 JSON 的 key 替换为你模型中需要的属性
             @"ID":@"id",

             };
    
}

+ (void)getDataWithPage:(NSInteger)page  SuccessBlock: (HttpRequestSuccess)successBlock failBlock:(HttpRequestFailed)failBlock {
    
    
    NSString *str = [NSString stringWithFormat:@"{\"page\" : \"%@\", \"pageSize\" : \"%@\"}", [RSA encryptString:[NSString stringWithFormat:@"%zd", page] publicKey:PublicKey], [RSA encryptString:@"10" publicKey:PublicKey]];

    [PPNetworkHelper POST:@"bargain/bargaingoods/goodsApp" parameters:@{@"json" : str} success:^(id responseObject) {
        
        NSLog(@"列表：%@", responseObject);
        
        NSArray *array = [NSArray arrayWithArray:responseObject[@"data"]];
        
        NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithDictionary:responseObject];
        
        if (array.count > 0) {
            
            NSArray *modelArr = [NewHomeModel mj_objectArrayWithKeyValuesArray:array];
            
            [dict removeObjectForKey:@"data"];
            [dict setObject:modelArr forKey:@"data"];
        }
        
        if (successBlock) {
            
            successBlock(dict);
        }
        
    } failure:^(NSError *error) {
        
        if (failBlock) {
            
            failBlock(error);
        }
    }];
    
   
    
}

@end
